import {useHistory} from "react-router-dom/cjs/react-router-dom";
import {connect, useDispatch, useSelector} from "react-redux";

function Home () {
    const history = useHistory()
    //使用useSelector获取到store的状态
    const result = useSelector( state => state )
    //调用dispatch函数
    const dispatch = useDispatch()
    return (
        <div>
            <p>
                页面一
            </p>
            <p>{result.count}</p>
            <p>
                <button onClick={ () => {
                    //dispatch返回一个store的实例，可以用它来实现action
                    dispatch( {type:'ADD'} )
                } }>click</button>
            </p>
            <p>
                <button onClick={ () => {
                    history.push('/list')
                } }>
                    跳转到页面二
                </button>
            </p>
        </div>
    )
}
export default Home